/**
 * $Revision: 1.0 $
 * $Author: Geln Yang $
 * $Date: May 19, 2010 9:39:35 PM $
 *
 * Author: Geln Yang
 * Date  : May 19, 2010 9:39:35 PM
 *
 */
package com.gooex.domain.common;

import java.io.Serializable;
import java.util.List;

/**
 * @author Geln Yang
 * @version 1.0
 */
public class Region implements Serializable {

	public static final String GLOBAL_REGION = "00";

	private String id;

	private String name;

	private long startip;

	private long endip;

	private Region parent;

	private List<Region> children;

	public String getFullName() {
		if (parent != null) {
			if (GLOBAL_REGION.equals(parent.getId()))
				return name;
			return parent.getFullName() + "," + name;
		}
		return name;
	}

	public boolean isMyChild(Region other) {
		return other != null && other.getId().startsWith(this.getId()) && this.id.length() < other.id.length();
	}

	public boolean isMyParent(Region other) {
		return other != null && other.isMyChild(this);
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Region getParent() {
		return parent;
	}

	public void setParent(Region parent) {
		this.parent = parent;
	}

	public List<Region> getChildren() {
		return children;
	}

	public void setChildren(List<Region> children) {
		this.children = children;
	}

	public long getStartip() {
		return startip;
	}

	public void setStartip(long startip) {
		this.startip = startip;
	}

	public long getEndip() {
		return endip;
	}

	public void setEndip(long endip) {
		this.endip = endip;
	}

}
